using Domain.Database;
using System.Data.Entity.ModelConfiguration;

namespace Domain.Mapping
{
    public class ConfigMap : EntityTypeConfiguration<Config>
    {
        public ConfigMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Key });

            // Properties
            this.Property(t => t.Title)
                .HasMaxLength(50);

            this.Property(t => t.Key)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Value)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.Description)
                .HasMaxLength(100);

            this.Property(t => t.CreateUser)
                .HasMaxLength(50);

            this.Property(t => t.ModifyUser)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Config");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.Key).HasColumnName("Key");
            this.Property(t => t.Value).HasColumnName("Value");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.IsForbidden).HasColumnName("IsForbidden");
            this.Property(t => t.CreateUser).HasColumnName("CreateUser");
            this.Property(t => t.ModifyUser).HasColumnName("ModifyUser");
            this.Property(t => t.AddTime).HasColumnName("AddTime");
            this.Property(t => t.ModifyTime).HasColumnName("ModifyTime");
        }
    }
}
